package io.github.i678.namedutils.api.utils;

import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.Date;

public class BanUtils {

    public static void kick(Player p) {
        if(p == null) throw new NullPointerException("Player cannot be null");
    }

    public static void ban(String ban, String reason, String banner, Date date) {
        Bukkit.getBanList(BanList.Type.NAME).addBan(ban, reason, date, banner);
    }

    public static void kickAll(String permission, String reason) {
        if(Bukkit.getOnlinePlayers().length == 0) throw new NullPointerException("There are no players online.");
        for(Player p : Bukkit.getOnlinePlayers()) {
            if(p.hasPermission(permission)) continue;
            p.kickPlayer(reason);
        }
    }

}